package com.ruoyi.operation.order.tablestatis.controller;

import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.operation.order.tablestatis.domain.TableStatis;
import com.ruoyi.operation.order.tablestatis.service.ITableStatisService;
import com.ruoyi.operation.order.total.domain.Total;
import com.ruoyi.operation.order.total.service.ITotalService;
import com.ruoyi.project.system.role.service.IRoleService;
import com.ruoyi.project.system.user.service.IUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Controller
@RequestMapping("/tableStatis/tableStatis")
public class TableStatisController extends BaseController {

    // 定义一个跳转到页面的路径
    private String prefix = "order/tablestatis/";
    @Autowired
    private IRoleService iRoleService;
    @Autowired
    private IUserService iUserService;
    @Autowired
    private ITotalService totalService;
    @Autowired
    private ITableStatisService tableStatisService;
    /**
     * 跳转到分析统计的页面
     * @return
     */
    @GetMapping()
    @RequiresPermissions(value = "tableStatis:tableStatis:tableStatis")
    String total(){
        return prefix + "tablestatis";
    }

    @RequestMapping(value = "/list")
    @RequiresPermissions(value = "tableStatis:tableStatis:tableStatis")
    @ResponseBody
    public TableDataInfo allEnertForm(TableStatis table){
        startPage();
        // 获取当前登陆人的id
//        String getUserId = ShiroUtils.getLoginId();
//
//        total.setUserName(getUserId);
        List<TableStatis> tableList=tableStatisService.seletBySta(table);
        return getDataTable(tableList);

    }

    /**
     * 导出订单信息
     * @param tableStatis
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping(value = "/exportExcel")
    @RequiresPermissions(value = "tableStatis:tableStatis:exportExcel" )
    public void exportExcel(TableStatis tableStatis, HttpServletRequest request, HttpServletResponse response) throws Exception{
        tableStatisService.exportTotal(tableStatis,request,response);
    }
}
